package cn.zysheep.observer.guava;

import com.google.common.eventbus.EventBus;

/**
 * @ClassName: EventBusCenter
 * @Author: lyw
 * @Date: 2022/10/27 14:28
 * @Description: Guava EventBus 基于注解的事件总线
 */
public class EventBusCenter {
    private static EventBus eventBus = new EventBus();

    public EventBusCenter() {
    }

    public static EventBus getInstance() {
        return eventBus;
    }
    //添加观察者
    public static void register(Object obj) {
        eventBus.register(obj);
    }

    //移除观察者
    public static void unregister(Object obj) {
        eventBus.unregister(obj);
    }

    //把消息推给观察者
    public static void post(Object obj) {
        eventBus.post(obj);
    }
}
